home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / font3d10.zip / TrueType.H < prev    next >
C/C++ Source or Header  |  1994-09-15  |  5KB  |  234 lines

  1. //=================================================================================================
  2. //   TrueType.H
  3. //
  4. //   Copyright (c) 1994 by Todd A. Prater
  5. //   All rights reserved.
  6. //
  7. //=================================================================================================
  8.  
  9. #ifndef __TrueType_H__
  10. #define __TrueType_H__
  11.  
  12. #include "Config.H"
  13. #include "Geometry.H"
  14.  
  15. #define OFFSET_TABLE_SIZE 12
  16.  
  17. class TTTableEntry
  18. {
  19.    public:
  20.       ULONG tag;
  21.       ULONG checkSum;
  22.       ULONG offset;
  23.       ULONG length;
  24.  
  25.       TTTableEntry(void)
  26.       {
  27.          tag      = 0x00000000;
  28.          checkSum = 0;
  29.          offset   = 0;
  30.          length   = 0;
  31.       }
  32. };
  33.  
  34.  
  35. class TTPoint
  36. {
  37.    public:
  38.       SHORT  type;
  39.       LONG   x;
  40.       LONG   y;
  41.  
  42.       TTPoint(void) 
  43.       { 
  44.          type=ON_CURVE; 
  45.          x=0; 
  46.          y=0;
  47.       }
  48.  
  49.       TTPoint(SHORT _type, LONG _x, LONG _y) 
  50.       { 
  51.          type=_type; 
  52.          x=_x; 
  53.          y=_y; 
  54.       }
  55.  
  56.       TTPoint(TTPoint& point) 
  57.       { 
  58.          type=point.type; 
  59.          x=point.x; 
  60.          y=point.y; 
  61.       }
  62. };
  63.  
  64.  
  65. class TTContour
  66. {
  67.    public:
  68.       USHORT numPoints;
  69.       TTPoint* points;
  70.  
  71.       TTContour(void) 
  72.       { 
  73.          numPoints=0; 
  74.          points=NULL; 
  75.       }
  76. };
  77.  
  78.  
  79. class TTGlyph
  80. {
  81.    public:
  82.       SHORT     numContours;
  83.       SHORT     xMin;
  84.       SHORT     yMin;
  85.       SHORT     xMax;
  86.       SHORT     yMax;
  87.       TTContour*  contours;
  88.  
  89.       TTGlyph(void) 
  90.       { 
  91.          numContours=0; 
  92.          contours=NULL; 
  93.       }
  94. };
  95.  
  96.  
  97. class TTFont
  98. {
  99.    USHORT numGlyphs;
  100.    TTGlyph* glyphs;
  101.  
  102.    USHORT maxPoints;
  103.    USHORT maxContours;
  104.    USHORT unitsPerEm;
  105.  
  106.    CHARPTR  copyrightString;
  107.    CHARPTR  familyString;
  108.    CHARPTR  subfamilyString;
  109.    CHARPTR  idString;
  110.    CHARPTR  fullnameString;
  111.    CHARPTR  versionString;
  112.    CHARPTR  psnameString;
  113.    CHARPTR  trademarkString;
  114.  
  115.  
  116.    USHORT   characterMap[256];
  117.    void     printbits(BYTE byte);
  118.  
  119. public:
  120.  
  121.    TTFont(CHARPTR filename);
  122.  
  123.    CHARPTR  Copyright(void)      { return copyrightString;  }
  124.    CHARPTR  Family(void)         { return familyString;     }
  125.    CHARPTR  Subfamily(void)      { return subfamilyString;  }
  126.    CHARPTR  UniqueID(void)       { return idString;         }
  127.    CHARPTR  FullName(void)       { return fullnameString;   }
  128.    CHARPTR  Version(void)        { return versionString;    }
  129.    CHARPTR  PSName(void)         { return psnameString;     }
  130.    CHARPTR  Trademark(void)      { return trademarkString;  }
  131.    USHORT   CharacterMap(int c)  { return characterMap[c];  }
  132.  
  133.    USHORT UnitsPerEm(void)  { return unitsPerEm;       }
  134.  
  135.    USHORT NumGlyphs(void)
  136.    {
  137.       return numGlyphs;
  138.    }
  139.  
  140.    SHORT NumContours(USHORT glyphnum)
  141.    {
  142.       if (numGlyphs!=0 && glyphnum<numGlyphs)
  143.          return glyphs[glyphnum].numContours;
  144.       else
  145.          return 0;
  146.    }
  147.  
  148.    USHORT NumPoints (USHORT glyphnum, USHORT contournum)
  149.    {
  150.       if( glyphnum<numGlyphs 
  151.           && glyphs[glyphnum].numContours>0 
  152.           && contournum<glyphs[glyphnum].numContours)
  153.          return glyphs[glyphnum].contours[contournum].numPoints;
  154.       else
  155.          return 0;
  156.    }
  157.  
  158.    LONG FontPointX (USHORT glyphnum, USHORT contournum, USHORT pointnum)
  159.    {
  160.       if( glyphnum<numGlyphs 
  161.           && glyphs[glyphnum].numContours>0 
  162.           && contournum<glyphs[glyphnum].numContours
  163.           && glyphs[glyphnum].contours[contournum].numPoints!=0
  164.           && glyphs[glyphnum].contours[contournum].numPoints!=0 )
  165.          return glyphs[glyphnum].contours[contournum].points[pointnum].x;
  166.       else
  167.          return 0;
  168.    }
  169.  
  170.    LONG FontPointY (USHORT glyphnum, USHORT contournum, USHORT pointnum)
  171.    {
  172.       if( glyphnum<numGlyphs
  173.           && glyphs[glyphnum].numContours>0
  174.           && contournum<glyphs[glyphnum].numContours
  175.           && glyphs[glyphnum].contours[contournum].numPoints!=0 )
  176.          return glyphs[glyphnum].contours[contournum].points[pointnum].y;
  177.       else
  178.          return 0;
  179.    }
  180.  
  181.    SHORT FontPointType (USHORT glyphnum, USHORT contournum, USHORT pointnum)
  182.    {
  183.       if( glyphnum<numGlyphs
  184.           && glyphs[glyphnum].numContours>0
  185.           && contournum<glyphs[glyphnum].numContours
  186.           && glyphs[glyphnum].contours[contournum].numPoints!=0 )
  187.          return glyphs[glyphnum].contours[contournum].points[pointnum].type;
  188.  
  189.  
  190.       else
  191.          return NO_POINT;
  192.    }
  193.  
  194.    SHORT GlyphXMin(USHORT glyphnum)
  195.    {
  196.       if (glyphnum<numGlyphs)
  197.          return glyphs[glyphnum].xMin;
  198.       else
  199.          return 0;
  200.    }
  201.  
  202.    SHORT GlyphYMin(USHORT glyphnum)
  203.    {
  204.       if (glyphnum<numGlyphs)
  205.          return glyphs[glyphnum].yMin;
  206.       else
  207.          return 0;
  208.    }
  209.  
  210.    SHORT GlyphXMax(USHORT glyphnum)
  211.    {
  212.       if (glyphnum<numGlyphs)
  213.          return glyphs[glyphnum].xMax;
  214.       else
  215.          return 0;
  216.    }
  217.  
  218.    SHORT GlyphYMax(USHORT glyphnum)
  219.    {
  220.       if (glyphnum<numGlyphs)
  221.          return glyphs[glyphnum].yMax;
  222.       else
  223.          return 0;
  224.    }
  225.  
  226.  
  227.    void Print(void);
  228.  
  229.  
  230. };
  231.  
  232.  
  233. #endif
  234.